﻿@model WaiGaoQiaoWeb.Models.YaxMachineVM
@{
    ViewBag.Title = "AddYaxMachine";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Head
{
    @Html.Css("EditForm")
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $("form").makeValidationInline();
            $("#btnSave").click(function (event) {
                var aaa1 = document.getElementById("tab1");
                var ass1;
                for (i = 0; i < aaa1.length; i++) {
                    if (aaa1[i].selected == true) {
                        ass1 = aaa1[i].innerText;
                        break;
                    }
                }
                if (ass1 != "串口") {
                    var vPortNo = document.getElementById("PortNo").value;
                    if (vPortNo == "" || vPortNo == null) {
                        document.getElementById("PortNo").value = 0;
                    }
                }
                if (!$("#fmEdit").valid()) {
                    return false;
                }
                $('#fmEdit').ajaxSubmit(function (callback) {
                    if (callback) {
                        CloseModelWindow(null, true);
                    }
                });
            });
            $("#btnCancel").click(function (e) {
                CloseModelWindow(null, false);
            });
        });

        function updateAvailable() {
            var aaa = document.getElementById("tab1");
            var ass;
            for (i = 0; i < aaa.length; i++) {
                if (aaa[i].selected == true) {
                    ass = aaa[i].innerText;
                    break;
                }
            }
            if (ass == "串口") {
                document.getElementById("div1").style.display = ""; //显示
                document.getElementById("div2").style.display = ""; //显示
                document.getElementById("div3").style.display = "none"; //隐藏
                document.getElementById("div4").style.display = "none"; //隐藏
                document.getElementById("div5").style.display = "none"; //隐藏
            }
            else {
                document.getElementById("div1").style.display = ""; //隐藏
                document.getElementById("div2").style.display = ""; //显示
                document.getElementById("div3").style.display = ""; //显示
                document.getElementById("div4").style.display = ""; //显示
                document.getElementById("div5").style.display = ""; //显示
            }
        }
    </script>
}
@using (Html.BeginForm("SaveYaxMachine", "YaxMachine", FormMethod.Post, new { id = "fmEdit" }))
{
    @Html.ValidationSummary(true)
    <div id="editFormWrapper">
        <br />
        <div class="editFormItems">
            <div class="editFormLabel">
                @Html.LabelFor(model => model.MacNoAdd)
            </div>
            <div class="editForm">
                @Html.EditorFor(model => model.MacNoAdd)<span style="color: Red;">*</span>
                @Html.ValidationMessageFor(model => model.MacNoAdd)
            </div>
        </div>
        <div class="editFormItems">
            <div class="editFormLabel">
                @Html.LabelFor(model => model.NodeName)
            </div>
            <div class="editForm">
                @Html.DropDownListFor(model => model.NodeName,
                              ViewData["NodeName"] as IEnumerable<SelectListItem>,
                                 new { @style = "width:180px; height:22px; font-size:13px;" })
                @Html.ValidationMessageFor(model => model.NodeName)
            </div>
        </div>
        <div class="editFormItems">
            <div class="editFormLabel">
                @Html.LabelFor(model => model.MacTypeName)
            </div>
            <div class="editForm">
                @Html.DropDownListFor(model => model.MacTypeName,
                           ViewData["MacTypeName"] as IEnumerable<SelectListItem>,
                                 new { @style = "width:180px; height:22px; font-size:13px;" })
                @Html.ValidationMessageFor(model => model.MacTypeName)
            </div>
        </div>
        <div class="editFormItems">
            <div class="editFormLabel">
                @Html.LabelFor(model => model.CommStyle)
            </div>
            <div class="editForm">
                @Html.DropDownListFor(model => model.CommStyle,
                        ViewData["CommStyle"] as IEnumerable<SelectListItem>,
                                 new { @style = "width:180px; height:22px; font-size:13px;", onchange = "updateAvailable()", id = "tab1" })
            </div>
        </div>
        <div class="editFormItems" id="div1">
            <div class="editFormLabel">
                @Html.LabelFor(model => model.PortNo)
            </div>
            <div class="editForm">
                @Html.TextBoxFor(model => model.PortNo)<span style="color: Red;">*</span>
                @Html.ValidationMessageFor(model => model.PortNo)
            </div>
        </div>
        <div class="editFormItems" id="div2">
            <div class="editFormLabel">
                @Html.LabelFor(model => model.BaudRate)
            </div>
            <div class="editForm">
                @Html.EditorFor(model => model.BaudRate)
                @Html.ValidationMessageFor(model => model.BaudRate)
            </div>
        </div>
        <div class="editFormItems" id="div3">
            <div class="editFormLabel">
                @Html.LabelFor(model => model.IPAddress)
            </div>
            <div class="editForm">
                @Html.EditorFor(model => model.IPAddress)
                @Html.ValidationMessageFor(model => model.IPAddress)
            </div>
        </div>
        <div class="editFormItems" id="div4">
            <div class="editFormLabel">
                @Html.LabelFor(model => model.GetwayIP)
            </div>
            <div class="editForm">
                @Html.EditorFor(model => model.GetwayIP)
                @Html.ValidationMessageFor(model => model.GetwayIP)
            </div>
        </div>
        <div class="editFormItems" id="div5">
            <div class="editFormLabel">
                @Html.LabelFor(model => model.SubIPAddr)
            </div>
            <div class="editForm">
                @Html.EditorFor(model => model.SubIPAddr)
                @Html.ValidationMessageFor(model => model.SubIPAddr)
            </div>
        </div>
        <div class="editFormItems">
            <div class="editFormLabel">
                @Html.LabelFor(model => model.MacDescribe)
            </div>
            <div class="editForm">
                @Html.TextBoxFor(model => model.MacDescribe, new { @style = "width:200px;" })
                @Html.ValidationMessageFor(model => model.MacDescribe)
            </div>
        </div>
    </div>
    <div class="buttonpanel">
        <div style="float: right; margin-right: 10px;">
            <a id="btnSave" href="javascript:void(0);" class="button"><span>保存</span></a> <a
                id="btnCancel" href="javascript:void(0);" class="button"><span>关闭</span></a>
        </div>
    </div>  
    <script type="text/javascript" language="javascript">
        document.getElementById("div1").style.display = ""; //显示
        document.getElementById("div2").style.display = ""; //显示
        document.getElementById("div3").style.display = "none"; //隐藏
        document.getElementById("div4").style.display = "none"; //隐藏
        document.getElementById("div5").style.display = "none"; //隐藏
    </script>
}
